<?php


namespace app\common\system\model;


use app\common\system\logic\UserLogic;
use think\Model;
use think\model\concern\SoftDelete;

class Notice extends Model
{
    protected $table = "tk_system_notice";
    use SoftDelete;
    protected $defaultSoftDelete = 0;

    protected $type = [
        'options' => 'json'
    ];

    public function getTitleAttr($value, $data) {
        $title = '';
        switch ($data['type']) {
            case 1:
                $title = '新客资跟进通知';
                break;
            case 2:
                $title = '转单通知';
                break;
            case 3:
                $title = '策划单通知';
                break;
            case 4:
                $title = '审核通知';
                break;
        }
        return $title;
    }

    public function getFromAttr($value, $data) {
        $userLogic = new UserLogic();
        return $userLogic->getUser($data['from_user_id'], ['id', 'realname']);
    }

    public function getUserAttr($value, $data) {
        $userLogic = new UserLogic();
        return $userLogic->getUser($data['user_id'], ['id', 'realname']);
    }

}